package com.zhytech.service;

import com.zhytech.Application;
import com.zhytech.beans.Quote;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;


@Service
public class RestClient {
	private static final Logger log = LoggerFactory.getLogger(Application.class);
	private String url  = "http://gturnquist-quoters.cfapps.io/api/random";



	public RestTemplate restTemplate(RestTemplateBuilder builder){
		return builder.build();
	}

	public Quote getQuote(){
		log.info("========  Before RestAPI  ===========");
		RestTemplate restTemplate = new RestTemplate();
		Quote quote = restTemplate.getForObject(url,Quote.class);
		log.info(quote.toString());
		return quote;
	}




}
